<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="Bookmark" href="favicon.ico" >
	<link rel="Shortcut Icon" href="favicon.ico" />
	<!--[if lt IE 9]>
	<script type="text/javascript" src="/public/lib/html5.js"></script>
	<script type="text/javascript" src="/public/lib/respond.min.js"></script>
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="/public/static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="/public/static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="/public/lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="/public/static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="/public/static/h-ui.admin/css/style.css" />
	<!--[if IE 6]>
	<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<title></title>
	<meta name="keywords" content="洛阳易购商城">
	<meta name="description" content="洛阳易购商城">
</head>
<body>
<article class="cl pd-20">
	<div class="form form-horizontal">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>广告位标题：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" autocomplete="off" value="" placeholder="广告位标题" class="input-text" id="ap_name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>广告位简介：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" autocomplete="off" value="" placeholder="广告位简介" class="input-text" id="ap_intro">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>宽度比例：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" autocomplete="off" value="" placeholder="宽度比例" class="input-text" id="width">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>高度比例：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" autocomplete="off" value="" placeholder="高度比例" class="input-text" id="height">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>排序：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input id="sort" type="number" placeholder="排序" class="input-text">
			</div>
		</div>
		<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" onclick="addAdvertAjax()" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		</div>
		</div>
	</div>
</article>
<script src="/public/menu/js/jquery-2.1.1.js"></script>
<script type="text/javascript" src="/public/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/public/static/h-ui/js/H-ui.js"></script>
<script src="/public/static/js/ajax_file_upload.js" type="text/javascript"></script>
<script src="/public/static/js/file_upload.js" type="text/javascript"></script>
<script type="text/javascript">
function on_upload() {
    $("#uploadImg").click();
}
//广告位图片上传
function imgUpload(event) {
    var fileid = $(event).attr("id");
    var str = $(event).next().attr("id");
    var data = { 'file_path' : "advert/" };
    uploadFile(fileid,data,function(res){
        if(res.code){
            $("#img"+str).attr("src",res.data);
            $("#"+str).val(res.data);
            layer.msg(res.message,{icon:1,time:1000});
        }else{
            layer.msg(res.message,{icon:1,time:1000});
        }
    });
}
function addAdvertAjax() {
    var ap_name = $("#ap_name").val();
    var ap_intro = $("#ap_intro").val();
    var sort = $("#sort").val();
    var height = $("#height").val();
    var width = $("#width").val();
    if(verify(ap_name,ap_intro,sort,width,height)){
        $.ajax({
            type : "post",
            url : "{:url('advert/addAdvertising')}",
            data : {
                'ap_name' : ap_name,
                'sort' : sort,
                'ap_intro' : ap_intro,
                'height' : height,
                'width' : width,
            },
            success : function(data) {
                if (data["code"] > 0) {
                    layer.msg('添加成功!',{icon:1,time:1000},function () {
                        window.parent.location.reload();
                    });
                }else{
                    layer.msg('添加失败',{icon:5,time:1000});
                }
            }
        });
    }
}
function verify(ap_name,ap_intro,sort,width,height){
       if(ap_name == ''){
           layer.msg('请输入名称',{icon:5,time:1000});
           $('#ap_name').focus();
           return false;
       }
    if(ap_intro == ''){
        layer.msg('请输入简介',{icon:5,time:1000});
        $('#ap_intro').focus();
        return false;
    }
    if(width == ''){
        layer.msg('请填写宽度比例',{icon:5,time:1000});
        $("#width").focus();
        return false;
    }
    if(height == ''){
        layer.msg('请填写高度比例',{icon:5,time:1000});
        $("#height").focus();
        return false;
    }
		if(sort == ''){
            layer.msg('请填写位置排序',{icon:5,time:1000});
			$("#sort").focus();
			return false;
		}
    return true;
}
</script>
</body>
</html>